﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Class_KetNoi
{
    public class KetNoi_NhanVien : KetNoiCoSoDuLieu
    {
        public void them_NhanVien(string @HoTen, string @GioiTinh, string @SoCMTND, string @Ngaysinh, string @NoiSinh, string @MaDT, string @MaPB, string @MaCV, string @DienThoai, string @HoKhau, string @ChoOHienNay, string @NgayVaoLam, string @SoBHYT, string @SoTheATM)
        {
            SqlCommand cmd = new SqlCommand("dbo.Insert_Employee", cnn);
            cmd.CommandType = CommandType.StoredProcedure;

            SqlParameter p = new SqlParameter("@HoTen", HoTen);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@GioiTinh", GioiTinh);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@SoCMTND",SoCMTND);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@Ngaysinh",Convert.ToDateTime( Ngaysinh));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@NoiSinh", NoiSinh);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaDT",Convert.ToInt32( MaDT));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaPB", Convert.ToInt32(MaPB));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaCV", Convert.ToInt32(MaCV));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@DienThoai", DienThoai);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@HoKhau", HoKhau);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@ChoOHienNay", ChoOHienNay);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@NgayVaoLam",Convert.ToDateTime( NgayVaoLam));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@SoBHYT", SoBHYT);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@SoTheATM", SoTheATM);
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();

        }
        public void sua_NhanVien(string @MaNV, string @HoTen, string @GioiTinh, string @SoCMTND, string @Ngaysinh, string @NoiSinh, string @MaDT, string @MaPB, string @MaCV, string @DienThoai, string @HoKhau, string @ChoOHienNay, string @NgayVaoLam, string @SoBHYT, string @SoTheATM)
        {
            SqlCommand cmd = new SqlCommand("dbo.updat_Employee", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@MaNV",MaNV);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@HoTen", HoTen);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@GioiTinh", GioiTinh);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@SoCMTND",SoCMTND);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@Ngaysinh",Convert.ToDateTime (Ngaysinh));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@NoiSinh", NoiSinh);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaDT", Convert.ToInt32(MaDT));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaPB", Convert.ToInt32(MaPB));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@MaCV", Convert.ToInt32(MaCV));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@DienThoai", DienThoai);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@HoKhau", HoKhau);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@ChoOHienNay", ChoOHienNay);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@NgayVaoLam",Convert.ToDateTime( NgayVaoLam));
            cmd.Parameters.Add(p);
            p = new SqlParameter("@SoBHYT", SoBHYT);
            cmd.Parameters.Add(p);
            p = new SqlParameter("@SoTheATM", SoTheATM);
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();

        }
        public void xoa_NhanVien(string @MaNV)
        {
            SqlCommand cmd = new SqlCommand("dbo.delete_Employee", cnn);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter p = new SqlParameter("@MaNV",MaNV);
            cmd.Parameters.Add(p);
            cmd.ExecuteNonQuery();

        }
    }
}
